#!/bin/bash
root=$(cd `dirname $0`; pwd)
buildFile=${root}/app/build.gradle  
while getopts :ali_key:ali_secert:hw_appid:vivo_key:vivo_appid:oppo_key:oppo_secret:mi_appid:mi_key:googleOn: ARGS  
do  
case $ARGS in   
    ali_key)  
       rep="s#28252002#"${OPTARG}"#g"
       replace rep  buildFile 
        ;;  
    ali_secert)  
        rep="s#d39c77c02fa2d0238318d18dba649ab8#"${OPTARG}"#g"
        replace rep  buildFile 
        ;;  
    hw_appid)  
        rep="s#100921793#"${OPTARG}"#g"
        replace rep  buildFile 
        ;;  
    vivo_key)  
        rep="s#6e835310dac54cf581357139e7c86530#"${OPTARG}"#g"
        replace rep  buildFile 
        ;;  
    vivo_appid)  
        rep="s#104323165#"${OPTARG}"#g"
        replace rep  buildFile 
        ;;  
    oppo_key)  
        rep="s#d32ff50e02094fc798bb39bf67cc8aa2#"${OPTARG}"#g"
        replace rep  buildFile 
        ;; 
    oppo_secret)  
        rep="s#8b3e0b0342284ab1ac3bdc2b04b76a93#"${OPTARG}"#g"
        replace rep  buildFile 
        ;;  
    mi_appid)  
        rep="s#2882303761518255792#"${OPTARG}"#g"
        replace rep  buildFile
        ;;  
    mi_key)  
        rep="s#5151825525792#"${OPTARG}"#g"
        replace rep  buildFile
        ;;
    google)  
        rep="s#COMPILE_SDK_USE_GOOGLE_PUSH=*#COMPILE_SDK_USE_GOOGLE_PUSH="${OPTARG}"#g"
        buildFile=buildFile=${root}/gradle.properties  
        replace rep  buildFile
        ;;                                
esac
done


function replace(){
	read rep
	readf file 
	if [ ! $rep ]|| [ ! $file ]; then
		echo '参数不对'
	else
	a=`uname  -a`
	if [[ $a =~ $mac ]];then
  		sed -i "" ${rep}  $file
	else
   		sed -i  ${rep}  $file
	fi
	fi
	
}